<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/tools/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/tools/font-awesome/css/font-awesome.css">
    <link rel="stylesheet" href="/css/comm.css">
    <style>
        html{
            height: auto;
        }
        .container-fluid{
               margin-top: 10px;
        }
        .btn-box{
            border-top:1px solid #eee;
            position: fixed;
            bottom:10px;
            left:0;
            width: 100%;
            text-align: right;
        }
        .btn-box .btn{
            margin-top: 10px;
            margin-right: 10px;
        }
        .form-horizontal .form-group{
            margin-right: 0;
            margin-left: 0;
        }
    </style>
</head>
<body>
<div class="container-fluid">
    <div class="row">
        <div class="col-md-12" id="app">
            <form class="form-horizontal row">
                <div class="form-group col-sm-6">
                    <label class="col-sm-3 control-label">账号：</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" v-model="params.username"/>
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-3 control-label">姓名：</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" v-model="params.name"/>
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-3 control-label">邮箱：</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" v-model="params.email"/>
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-3 control-label">手机：</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" v-model="params.telephone"/>
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-3 control-label">角色：</label>
                    <div class="col-sm-8">
                        <select  class="form-control"  v-model="params.roleId">
                            <option v-for="(item,index) in roleList" :value="item.id">{{ item.name }}</option>
                        </select>
                    </div>
                </div>
                <div class="btn-box col-xs-12">
                    <button class="btn btn-default" @click="add" type="button"><i class="fa fa-save"></i>保存</button>
                </div>
            </form>
        </div>
    </div>
</div>
<script src="/tools/jquery/jquery-3.2.1.min.js"></script>
<script src="/tools/bootstrap/js/bootstrap.min.js"></script>
<script src="/tools/vue.min.js"></script>
<script src="/javaScript/vue-nav.js"></script>
<script src="/tools/layer/layer.js"></script>
<script src="/javaScript/common.js"></script>
<script src="/javaScript/ajaxDataController.js"></script>
<script type="application/javascript">
    var userId  = common.request.getParam("id");
    var vue = new Vue({
        el: "#app",
        data: {
            roleList:[],
            params: {}
        },
        created: function () {
            ajaxDataController().post("/role/getRoleList",null,function(data){
                vue.roleList = data.resultObject;
            });
            ajaxDataController().post("/user/getUser",{id:userId},function(data){
                vue.params = data.resultObject;
            });
        },
        methods: {
            add: function(){
                vue.params.id= userId;
                ajaxDataController().post("/user/updateUser",vue.params,function(data){
                    common.layer.success("保存成功",function(){
                        parent.layer.closeAll();
                        parent.vue.callback(1);
                    });
                });
            }
        }
    });
</script>
</body>
</html>